package com.yyh.xiancheng2;

public class Test4 {
    public static void main(String[] args) {
        Runnable r1 = new MyRunnable();
        Runnable r2 = new MyRunnable();
        Thread t1 = new Thread(r1, "前台线程");
        Thread t2 = new Thread(r2, "后台线程");
        t1.start();
        t2.setDaemon( true);
        t2.start();
    }
}
class MyRunnable implements Runnable{
    @Override
    public void run() {
        for (int i = 1; i <= 10; i++) {
            System.out.println(Thread.currentThread().getName() + "：" + i);
        }
    }
}
class MyRunnable2 implements Runnable{
    @Override
    public void run() {
        for (int i = 1; i <= 20; i++) {
            System.out.println(Thread.currentThread().getName() + "：" + i);
        }
    }
}
